package com.team.app.util;

public class FormatUtil {
	public static boolean isPhone(String phoneNo){
		if (phoneNo.matches("\\d{10,11}")) return true;
        //validating phone number with -, . or spaces
        else if(phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true;
        //validating phone number with extension length from 3 to 5
        else if(phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true;
        //validating phone number where area code is in braces ()
        else if(phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")) return true;
        //return false if nothing matches the input
        else return false;
	}
	public static boolean isEmail(String email){
		String REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
		return email.matches(REGEX);
	}
	
	public static boolean isNumber(String number){
		String REGEX = "\\d";
		return number.matches(REGEX);
	}
	public static boolean isAlphaNumber(String alphaNumber){
		String REGEX = "^[a-zA-Z0-9]*$";
		return alphaNumber.matches(REGEX);
	}
}
